#!/bin/sh

# Simple start wrapper (C) 2015 by Jim Klimov for gnome-connection-manager
# Install this script as /usr/bin/gcm
# Requires the GCM itself: http://kuthulu.com/gcm/?module=download
# unpacked as /usr/share/gcm (may be a symlink to actual version)
# and its dependencies (python v2.6+, glade, X11, etc.)

if [ -z "$DISPLAY" ]; then
	echo "FATAL: The DISPLAY variable is not set and is required!" >&2
	exit 1
fi

# Empirically it seems that for GCM interface to be properly localized,
# the LANGUAGE should be just the two-character code
if [ -z "${LANGUAGE-}" ]; then
	[ -n "${LANG-}" ] && \
		LANGUAGE="$LANG" || \
		LANGUAGE=en
fi
[ "$LANGUAGE" = en ] || \
	LANGUAGE="`echo "$LANGUAGE" | sed 's,^\(..\).*$,\1,'`"

export LANGUAGE LANG LC_ALL DISPLAY
echo "Starting gnome-connection-manager with LANGUAGE=$LANGUAGE ..."
locale 2>/dev/null
exec /usr/share/gnome-connection-manager/gnome_connection_manager.py "$@"

